package com.mqtt.ctwingmqtt.domain;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class PageResult<T> {
    private Long total;      // 总记录数
    private List<T> records; // 当前页数据
    private Long pageNum;    // 当前页码
    private Long pageSize;   // 每页数量

    public PageResult(Page<T> page) {
        this.total = page.getTotal();
        this.records = page.getRecords();
        this.pageNum = page.getCurrent();
        this.pageSize = page.getSize();
    }
}